package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {
    // 根据用户名查询数据库
    @Select("select * from employee where username=#{username}")
    Employee getByUsername(String username);

    // 员工列表分页查询
    List<Employee> findList(EmployeePageQueryDTO employeePageQueryDTO);

    // 员工新增
    @AutoFill("insert")//AOP自动填充       //内容要按照实体类, 顺序要按照数据表
    @Insert("insert into employee values (null,#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Employee employee);

    //回显->根据主键id查询
    @Select("select * from employee where id = #{id}")
    Employee findById(Long id);

    //修改->更新员工
    @AutoFill("update")//AOP自动填充
    void update(Employee employee);
}
